package br.com.jvet.entidade;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@Table(name = "tbexame")
@SequenceGenerator(name = "exame_seq", sequenceName = "exame_seq", initialValue = 1, allocationSize = 1)
public class Exame implements Serializable {

	private static final long serialVersionUID = -2346810260247364164L;
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "exame_seq")
	private Integer codigo;
	@Column(length = 150)
	private String descricao;
	@Column
	private String preparo;
	@OneToOne
	private TipoExame tipoExame;
	@Column(precision = 2)
	private double precoCobrado;

	public Exame() {
		super();
		tipoExame = new TipoExame();

	}

	public Exame(Integer codigo) {
		super();
		this.codigo = codigo;
	}

	public Integer getCodigo() {
		return codigo;
	}

	public void setCodigo(Integer codigo) {
		this.codigo = codigo;
	}

	public String getDescricao() {
		return descricao;
	}

	public void setDescricao(String descricao) {
		this.descricao = descricao;
	}

	public String getPreparo() {
		return preparo;
	}

	public void setPreparo(String preparo) {
		this.preparo = preparo;
	}

	public TipoExame getTipoExame() {
		return tipoExame;
	}

	public void setTipoExame(TipoExame tipoExame) {
		this.tipoExame = tipoExame;
	}

	public double getPrecoCobrado() {
		return precoCobrado;
	}

	public void setPrecoCobrado(double precoCobrado) {
		this.precoCobrado = precoCobrado;
	}

	@Override
	public String toString() {
		return "Exame [codigo=" + codigo + ", descricao=" + descricao
				+ ", preparo=" + preparo + ", tipoexame=" + tipoExame + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + codigo;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Exame other = (Exame) obj;
		if (codigo != other.codigo)
			return false;
		return true;
	}

	public Exame clone() {
		Exame exame = new Exame();
		exame.setCodigo(codigo);
		exame.setDescricao(descricao);
		exame.setPreparo(preparo);
		exame.setTipoExame(tipoExame);
		exame.setPrecoCobrado(precoCobrado);
		return exame;
	}

}
